package com.swak.utils;

public class Doubles {

	/**
	 * nullToZero
	 *
	 * @param value 数据
	 * @return 整数
	 */
	public static double nullToZero(Double value) {
		return value == null ? 0.0 : value;
	}

	/**
	 * 整形的添加
	 *
	 * @param values 多个数据
	 * @return 结果
	 */
	public static double addI(Double... values) {
		double num = 0;
		if (values != null && values.length != 0) {
			for (Double value : values) {
				num = BigDecimalUtil.add(num, nullToZero(value));
			}
		}
		return num;
	}

	/**
	 * 整形的减法
	 *
	 * @param minuend 被减数
	 * @param subs    减数
	 * @return 结果
	 */
	public static double subI(Double minuend, Double... subs) {
		if (subs != null && subs.length != 0) {
			for (Double value : subs) {
				minuend = BigDecimalUtil.sub(nullToZero(minuend), nullToZero(value));
			}
		}
		return nullToZero(minuend);
	}

	/**
	 * 乘法
	 * 
	 * @param minuend
	 * @param subs
	 * @return
	 */
	public static double mulI(Double minuend, Double... subs) {
		if (subs != null && subs.length != 0) {
			for (Double value : subs) {
				minuend = BigDecimalUtil.mul(nullToZero(minuend), nullToZero(value));
			}
		}
		return nullToZero(minuend);
	}
}
